from pydantic import BaseModel, Field
from typing import Optional, Dict, Any
from uuid import UUID
from datetime import datetime

class DeviceBase(BaseModel):
    name: str = Field(..., min_length=1, max_length=255)
    device_type: str = Field(..., min_length=1, max_length=100)
    model: Optional[str] = None
    manufacturer: Optional[str] = None
    location: Optional[str] = None
    specifications: Optional[Dict[str, Any]] = None
    description: Optional[str] = None

class DeviceCreate(DeviceBase):
    pass

class DeviceUpdate(BaseModel):
    name: Optional[str] = None
    device_type: Optional[str] = None
    model: Optional[str] = None
    location: Optional[str] = None
    specifications: Optional[Dict[str, Any]] = None
    status: Optional[str] = None

class DeviceResponse(DeviceBase):
    id: UUID
    status: str
    owner_id: UUID
    created_at: datetime
    updated_at: Optional[datetime]
    last_maintenance: Optional[datetime]
    
    class Config:
        from_attributes = True